home *** CD-ROM | disk | FTP | other *** search
/ Belgian Amiga Club - ADF Collection / BS1 part 05.zip / BS1 part 5 / PDraw3.0.adf / pdraw_rex.lzh / SavePrefs.pdrx < prev    next >
Text File  |  1992-06-22  |  5KB  |  172 lines

  1. /*
  2. @N
  3.  
  4. This Genie will save any settings in the current PDraw environment to a config file. Professional Draw will then always start up with your specified settings. (Example: Magnification, WireFrame, Interlace, etc...) 
  5.  
  6. */
  7. msg = PDSetup.rexx(2,0)
  8. units =getclip(pds_units)
  9. if msg ~= 1 then exit_msg(msg)
  10.  
  11. cr  = '0a'x
  12. call pdm_SetBatchMode(1)
  13. startprefs  = "/*****Start Prefs*****/"
  14. endprefs    = "/*****End Prefs*****/"
  15. startsave   = "/*****StartSave*****/"
  16. endsave     = "/*****EndSave*******/"
  17. startupfile = "s:pdraw.config"
  18. pdcolors = "s:pdcolors.dflt"
  19. startup     = ''
  20. clist       = 0
  21.  
  22. selection   = "Units"
  23. selection   = selection || cr"Grid Size"
  24. selection   = selection || cr"Grid"
  25. selection   = selection || cr"Ruler"
  26. selection   = selection || cr"Grid Snap"
  27. selection   = selection || cr"Ruler Type"
  28. selection   = selection || cr"Dither Mode"
  29. selection   = selection || cr"Fill Pattern"
  30. selection   = selection || cr"Interlace"
  31. selection   = selection || cr"Line Color"
  32. selection   = selection || cr"Line Pattern"
  33. selection   = selection || cr"Line Join"
  34. selection   = selection || cr"Line Weight"
  35. selection   = selection || cr"Color Mode"
  36. selection   = selection || cr"Quick Move"
  37. selection   = selection || cr"Wire Frame"
  38. selection   = selection || cr"Workbench"
  39.  
  40. counter = 1
  41.  
  42. if exists(startupfile) then
  43. do
  44.  /*  if exists then read file into line array and separate sections  */
  45.     if ~open(file, startupfile, "r") then
  46.         call exit_msg("DOS error. Unable to create a configuration file.")
  47.  
  48.     do while ~eof(file)
  49.  
  50.         text = strip(readln(file))
  51.   if text = '' then iterate
  52.  
  53.         if text = startprefs then
  54.   do while ~eof(file)
  55.  
  56.    text = readln(file)
  57.    if text = endprefs then leave
  58.  
  59.   end
  60.         else if text = startsave then
  61.   do while ~eof(file)
  62.  
  63.    text = readln(file)
  64.          if text = endsave then leave
  65.  
  66.   end
  67.   else
  68.          startup = startup || cr || text
  69.  
  70.     end
  71.  
  72.     call close(file)
  73. end
  74. else
  75. do
  76.  startup = "/*"cr"Professional Draw Configuration File"cr"*/"cr
  77.  startup = startup"if ~show(l, 'rexxsupport.library') then"cr"if ~addlib('rexxsupport.library', 0, -30) then"cr"do"cr"call pdm_Inform(1,'You may need to install the rexxsupport.library in your libs: directory before running any Genies.',)"cr"end"cr
  78.  startup = startup"if ~show(l, 'gdarexxsupport.library') then"cr"if ~addlib('gdarexxsupport.library', 0, -30) then"cr"do"cr"call pdm_Inform(1,'You may need to install the gdarexxsupport.library in your libs: directory before running any Genies.',)"cr"end"
  79.  startup = startup || cr
  80. end
  81.  
  82.  
  83. if exists(startupfile) then
  84. do
  85.     address command
  86.     'copy' startupfile startupfile".bak"
  87.     address
  88. end
  89.  
  90. selection   = compress(pdm_SelectFromList("Select Settings to Save", 20, 12, 1, selection))
  91. if selection = '' then exit_msg()
  92.  
  93. call pdm_ShowStatus("Working")
  94.  
  95. call pdm_SaveColorList(pdcolors) 
  96.  
  97. startup = startup || cr || startprefs || cr"call pdm_AutoUpdate(0)"cr
  98. startup = startup"call pdm_LoadColorList('"pdcolors"')"cr
  99.  
  100. special = "LineWeight LineColor LineJoin"
  101.  
  102. upos = pos('Units', selection)
  103.  
  104. if upos ~= 0 then
  105.    selection = delstr(selection, upos, 6) || '0a'x || "Units"
  106.  
  107. do while selection ~= ''
  108.  
  109.     parse var selection command '0a'x selection
  110.     command = strip(command)
  111.  
  112.     if command = '' then iterate
  113.  
  114.     interpret "setting = pdm_Get"command"()"
  115.  
  116.  if  command = "FillPattern" then
  117.  do
  118.   parse var setting gradtype '0a'x color1 '0a'x color2 '0a'x steps '0a'x angle '0a'x centerx '0a'x centery
  119.   setting = ","gradtype",'"color1"','"color2"',"steps","angle","centerx","centery
  120.  end
  121.  else if command = "LinePattern" then
  122.   setting = "," || word(setting, 1) || ",'" || subword(setting, 2)"'"
  123.  else if command = "Units" then
  124.    setting = units
  125.  else if pos(command, special) ~= 0 then
  126.   setting = ",'"setting"'"
  127.  else if words(setting) > 1 then
  128.         setting = separate(setting, ',')
  129.     else if ~datatype(setting,n) then setting = '"'setting'"'
  130.  
  131.     command = "call pdm_Set"command"("setting")"
  132.     startup = startup || cr || command
  133. end
  134.  
  135. startup = startup || cr"call pdm_AutoUpdate(1)"cr ||  endprefs
  136.  
  137. if pdm_Inform(2, "Would you like to have the AutoSave Genie run upon startup?", "No", "Yes") then
  138.     startup  = startup || cr||startsave||cr"address command"cr"'rx' 'rexx:AutoSave.pdrx'"cr||endsave
  139.  
  140. if ~open(file, startupfile, "w") then exit_msg("Unable to open config file")
  141. call writeln(file, startup)
  142.  
  143. call close(file)
  144.  
  145. call pdm_ShowStatus("Done")
  146.  
  147. exit_msg()
  148.  
  149. separate: procedure
  150. do
  151.  parse arg string, separator
  152.  
  153.  string = replacestring(string, ' ', separator, 0)
  154.  return(string)
  155. end
  156.  
  157. exit_msg: expose units
  158. do
  159.  
  160.     parse arg message
  161.  
  162.     if message ~= '' then
  163.         call pdm_Inform(1, message,)
  164.  
  165.  call pdm_SetUnits(units)
  166.     call pdm_ClearStatus()
  167.  call pdm_SetBatchMode(0)
  168.     call pdm_AutoUpdate(1)
  169.     exit
  170.  
  171. end
  172.